#-*- coding:utf-8 -*-
from django.shortcuts import render,render_to_response,HttpResponse,HttpResponseRedirect
from data import models as data_models
import datetime

# Create your views here.
def getTime(request,*args):
    return HttpResponse(datetime.datetime.now())


def server(request,*args):
    r_data = {}
    pageData = data_models.server_main.objects.all().order_by('main_ip')
    r_data['pageData']=pageData

    return render_to_response('assets/server.html',r_data)

def serverDetails(request,*args):
    main_ip = request.GET.get('ip')
    partition_obj = data_models.server_partition.objects.filter(server_main__main_ip=main_ip).order_by('file_system')
    memory_obj = data_models.server_memory.objects.filter(server_main__main_ip=main_ip).order_by('serial')
    network_obj = data_models.server_network.objects.filter(server_main__main_ip=main_ip).order_by('interface')
    tomcat_obj = data_models.server_tomcat.objects.filter(server_main__main_ip=main_ip).order_by('port')

    r_data = {'partition_obj':partition_obj,'memory_obj':memory_obj,'network_obj':network_obj,'tomcat_obj':tomcat_obj}
    #print main_ip

    return render_to_response('assets/serverDetails.html',r_data)